#include<stdio.h>
#include<math.h>
typedef long long ll;
ll n, m, s;
ll p[100005], A[100005], B[100005], C[100005];
ll b[100005];
ll num[100005], sum=0;
int main()
{
	scanf("%lld%lld", &n, &m);
	for (int i = 1; i <= m; i++)
	{
		scanf("%lld", &p[i]);
	}
	for (int i = 1; i <n; i++)
	{
		scanf("%lld%lld%lld", &A[i], &B[i], &C[i]);
	}
	for (int i = 2; i <= m; i++)
	{
		int l = p[i - 1];
		int r = p[i];
		if (l > r)
		{
			int t;
			t = l;
			l = r;
			r = t;
		}
		b[l]++;
		b[r]--;
	}
	for (int i = 1; i < n; i++)
	{
		num[i] = num[i - 1] + b[i];//这段铁路乘坐次数
		if (A[i] * num[i] < C[i] + B[i] * num[i])
		{
			sum += A[i] * num[i];
		}
		else
		{
			sum += C[i] + B[i] * num[i];
		}
	}
	printf("%d", sum);

}